package com.ruoyi.member.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.member.domain.MessageReceive;
import com.ruoyi.member.service.IMessageReceiveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 我的消息Controller
 * 
 * @author renyuxin
 * @date 2024-06-13
 */
@RestController
@RequestMapping("/member/messageReceive")
public class MessageReceiveController extends BaseController
{
    @Autowired
    private IMessageReceiveService messageReceiveService;

    /**
     * 查询我的消息列表
     */
    @PreAuthorize("@ss.hasPermi('member:messageReceive:list')")
    @GetMapping("/list")
    public TableDataInfo list(MessageReceive messageReceive)
    {
        startPage();
        List<MessageReceive> list = messageReceiveService.selectMessageReceiveList(messageReceive);
        return getDataTable(list);
    }

    /**
     * 导出我的消息列表
     */
    @PreAuthorize("@ss.hasPermi('member:messageReceive:export')")
    @Log(title = "我的消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MessageReceive messageReceive)
    {
        List<MessageReceive> list = messageReceiveService.selectMessageReceiveList(messageReceive);
        ExcelUtil<MessageReceive> util = new ExcelUtil<MessageReceive>(MessageReceive.class);
        util.exportExcel(response, list, "我的消息数据");
    }

    /**
     * 获取我的消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:messageReceive:query')")
    @GetMapping(value = "/{messageMyId}")
    public AjaxResult getInfo(@PathVariable("messageMyId") Long messageMyId)
    {
        return success(messageReceiveService.selectMessageReceiveByMessageMyId(messageMyId));
    }

    /**
     * 新增我的消息
     */
    @PreAuthorize("@ss.hasPermi('member:messageReceive:add')")
    @Log(title = "我的消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MessageReceive messageReceive)
    {
        return toAjax(messageReceiveService.insertMessageReceive(messageReceive));
    }

    /**
     * 修改我的消息
     */
    @PreAuthorize("@ss.hasPermi('member:messageReceive:edit')")
    @Log(title = "我的消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MessageReceive messageReceive)
    {
        return toAjax(messageReceiveService.updateMessageReceive(messageReceive));
    }

    /**
     * 删除我的消息
     */
    @PreAuthorize("@ss.hasPermi('member:messageReceive:remove')")
    @Log(title = "我的消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{messageMyIds}")
    public AjaxResult remove(@PathVariable Long[] messageMyIds)
    {
        return toAjax(messageReceiveService.deleteMessageReceiveByMessageMyIds(messageMyIds));
    }
}
